<?php

namespace app\admin\controller;

use app\common\model\UserModel;
use think\Db;

class Index extends Common
{

    public function index(){

        $recyclerWhere= [];
        $weightWhere= [];
        $priceWhere= [];

        if(ADMINTYPE ==2){
            $recyclerWhere[] = ["region_id","=",$this->adminInfo["region_id"]];
            $priceWhere[] = ["region_id","=",$this->adminInfo["region_id"]];
            $orderS = Db::name('orders')->where("region_id",$this->adminInfo["region_id"])->field("id")->select();
            $in  = [];
            foreach ($orderS as $v){
                $in[] = $v["id"];
            }
            $weightWhere[] = ["order_id","in",$in];
        }

        $data['userCount'] = UserModel::count("*");
        $data['recycler'] = UserModel::where('user_class',2)->where($recyclerWhere)->count("*");
        $data['weight'] = Db::name('order_detail')->where($weightWhere)->sum("number");
        $data['price'] = Db::name('orders')->where($priceWhere)->where('order_status',2)->sum("total_money");
        return view('',['info'=>$data]);
    }
}